﻿<UserControl xmlns:my3="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ExpressionDark"  xmlns:my2="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ShinyBlue"  xmlns:my1="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ExpressionLight"  xmlns:twilightBlue="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.TwilightBlue"  xmlns:my="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.WhistlerBlue"  

             x:Class="eventr.View.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Util="clr-namespace:eventr.View.Util"
    xmlns:View="clr-namespace:eventr.View"
    xmlns:Controls="clr-namespace:eventr.Controls"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    Width="Auto" Height="Auto"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="797" d:DesignHeight="613" 
    xmlns:SuperDeepZoom="clr-namespace:SuperDeepZoom;assembly=SuperDeepZoom"
    xmlns:controls2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" >
    <UserControl.Resources>

        <ControlTemplate x:Key="refinementButtonTemplate" TargetType="Button">
            <Grid>
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="FocusStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.1000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Unfocused"/>
                        <vsm:VisualState x:Name="Focused"/>
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="CommonStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.1000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="normal" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="down" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="hover" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Normal"/>
                        <vsm:VisualState x:Name="Pressed">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="normal" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="hover" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="down" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Disabled"/>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <Image Height="26" x:Name="normal" Width="26" Source="/images/blank_rest.png" Stretch="Fill"/>
                <Image Height="26" x:Name="down" Width="26" Opacity="0" Source="/images/blank_pressed.png" Stretch="Fill"/>
                <Image Height="26" x:Name="hover" Width="26" Opacity="0" Source="/images/blank_hover.png" Stretch="Fill"/>
            </Grid>
        </ControlTemplate>
        
        <Style x:Key="SpecialImageOverlayItemStyle" TargetType="SuperDeepZoom:SpecialImageOverlayItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="SuperDeepZoom:SpecialImageOverlayItem">
                        <Grid x:Name="SpecialOverlayRoot">                                   
                            <View:ImageOverlay/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <ControlTemplate x:Key="SpecialImageOverlayControlTemplate" TargetType="SuperDeepZoom:SpecialImageOverlay">
            <Grid x:Name="grid">
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="VisibilityStates">
                        <vsm:VisualStateGroup.Transitions>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Visible">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="00:00:00.0010000">
                                	<DiscreteObjectKeyFrame KeyTime="00:00:00">
                                		<DiscreteObjectKeyFrame.Value>
                                			<Visibility>Visible</Visibility>
                                		</DiscreteObjectKeyFrame.Value>
                                	</DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
                                	<SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.995"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>

                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Invisible">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
                                	<SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)">
                                	<DiscreteObjectKeyFrame KeyTime="00:00:00.6000000">
                                		<DiscreteObjectKeyFrame.Value>
                                			<Visibility>Collapsed</Visibility>
                                		</DiscreteObjectKeyFrame.Value>
                                	</DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>

                        </vsm:VisualState>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <ItemsPresenter/>
            </Grid>
        </ControlTemplate>

        <!--FlyThroughOverlayStyle allows customisation of the flythrough overlay-->
        <Style x:Key="FlyThroughOverlayStyle" TargetType="SuperDeepZoom:FlyThroughOverlayItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="SuperDeepZoom:FlyThroughOverlayItem">

                        <Grid x:Name="FlyThroughRoot" Height="20">

                            <!--Customise the overlay line here-->
                            <!--Ensure your controls stretch 100% wide, as the size will be altered
                                by code -->
                            <!--<Rectangle Height="10" VerticalAlignment="Center" Fill="Green" Margin="0,0,0,0" Width="Auto" />
                            <Ellipse HorizontalAlignment="Left" Margin="-10,0,0,0" Width="20" Fill="Red" Stroke="#FF000000" Height="20" VerticalAlignment="Center"/>
                            <Ellipse HorizontalAlignment="Right" Margin="0,0,-10,0" Width="20" Fill="Red" Stroke="#FF000000" Height="20" VerticalAlignment="Center"/>-->
                            
                            <View:FlyThoughOverlayLineDisplay/>
                            
                        </Grid>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        

        <ItemsPanelTemplate x:Key="FlyThroughOverlayItemsPanelTemplate">
            <Canvas/>
        </ItemsPanelTemplate>
        <ControlTemplate x:Key="FlyThroughOverlayControlTemplate" TargetType="SuperDeepZoom:FlyThroughOverlay">
        	<Grid x:Name="grid">
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="VisibilityStates">
                        <vsm:VisualStateGroup.Transitions>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Visible">
                        	<Storyboard>
                        		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="00:00:00.0010000">
                        			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                        				<DiscreteObjectKeyFrame.Value>
                        					<Visibility>Visible</Visibility>
                        				</DiscreteObjectKeyFrame.Value>
                        			</DiscreteObjectKeyFrame>
                        		</ObjectAnimationUsingKeyFrames>
                        		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
                        			<SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.995"/>
                        		</DoubleAnimationUsingKeyFrames>
                        	</Storyboard>

                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Invisible">
                        	<Storyboard>
                        		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
                        			<SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0"/>
                        		</DoubleAnimationUsingKeyFrames>
                        		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)">
                        			<DiscreteObjectKeyFrame KeyTime="00:00:00.5000000">
                        				<DiscreteObjectKeyFrame.Value>
                        					<Visibility>Collapsed</Visibility>
                        				</DiscreteObjectKeyFrame.Value>
                        			</DiscreteObjectKeyFrame>
                        		</ObjectAnimationUsingKeyFrames>
                        	</Storyboard>

                        </vsm:VisualState>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <ItemsPresenter/>
            </Grid>
        </ControlTemplate>
 
        <ControlTemplate x:Key="SuperDeepZoomControlTemplate" TargetType="SuperDeepZoom:SuperDeepZoom">
            <Grid>
                
                <!--This is a control that is referenced by the TemplatePart in SuperDeepZoom.cs (right at the top)-->
                <MultiScaleImage x:Name="RootMultiScaleImage" KeyDown="LayoutRoot_KeyDown" />

                <!--This is a control that is referenced by the TemplatePart in SuperDeepZoom.cs (right at the top)-->
                <!--<SuperDeepZoom:FlyThroughOverlay x:Name="FlyThroughOverlay" ItemContainerStyle="{StaticResource FlyThroughOverlayStyle}" ItemsPanel="{StaticResource FlyThroughOverlayItemsPanelTemplate}" Template="{StaticResource FlyThroughOverlayControlTemplate}"/>-->
                <SuperDeepZoom:SpecialImageOverlay x:Name="SpecialImageOverlay" ItemContainerStyle="{StaticResource SpecialImageOverlayItemStyle}" ItemsPanel="{StaticResource FlyThroughOverlayItemsPanelTemplate}" Template="{StaticResource SpecialImageOverlayControlTemplate}"/>
            </Grid>
        </ControlTemplate>
        
        <Storyboard x:Name="LeftPanelHide">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LeftPanelBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <EasingDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:01" Storyboard.TargetName="LeftPanelBorder" Storyboard.TargetProperty="(UIElement.Visibility)">
                <DiscreteObjectKeyFrame KeyTime="00:00:01">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Collapsed</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>

        <Storyboard x:Name="LeftPanelShow">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LeftPanelBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <EasingDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LeftPanelBorder" Storyboard.TargetProperty="(UIElement.Visibility)">
                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Visible</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>

        <Util:RefinerValueFormatter x:Name="RefinementFormatter" />

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="{x:Null}" KeyDown="LayoutRoot_KeyDown">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <controls2:BusyIndicator x:Name="SearchingIndicator" Background="#CCFFFFFF" BusyContent="Searching..." Grid.Row="0" Grid.RowSpan="2"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="18" Foreground="White" IsBusy="False">
            <SuperDeepZoom:SuperDeepZoom x:Name="SuperDeepZoomer" SpecialImageOverlayEnabled="{Binding SpecialImageOverlayEnabled}"  FlyThroughOverlayEnabled="False" ImageContextData="{Binding ImageContextData}"  DeepZoomSource="{Binding DeepZoomSource}" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Template="{StaticResource SuperDeepZoomControlTemplate}"/>
        </controls2:BusyIndicator>

        <Border Grid.Row="0" Grid.RowSpan="2" OpacityMask="Black" x:Name="LeftPanelBorder" Padding="10"  Margin="0,0,0,0" CornerRadius="5" VerticalAlignment="Stretch" Width="Auto" HorizontalAlignment="Left" Opacity="0" Visibility="Collapsed">
            <Border.Background>
                <LinearGradientBrush StartPoint="0.499999,1.27948e-006" EndPoint="0.499999,1">
                    <GradientStop Color="#FFE8E8E9" Offset="0"/>
                    <GradientStop Color="#D7E8E8E9" Offset="0.662582"/>
                    <GradientStop Color="#FFC6C7C9" Offset="0.792828"/>
                    <GradientStop Color="#FFA5A7AA" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Border.RenderTransform>
                <TransformGroup>
                    <TranslateTransform/>
                </TransformGroup>
            </Border.RenderTransform>
            <!---->
                <StackPanel Orientation="Vertical" >
                <TextBlock Margin="8,10, 10, 10" HorizontalAlignment="Center" Foreground="Black" Text="Search Refinement" FontSize="16" FontWeight="Bold"  FontFamily="Arial"/>
                <ItemsControl x:Name="refinementPanel" Padding="10" ItemsSource="{Binding Refiners}" VerticalAlignment="Stretch" Height="Auto" Margin="3,3,3,3" HorizontalAlignment="Left" Width="250" Background="{x:Null}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            
                                <Border BorderThickness="1" CornerRadius="5" >

                                    <StackPanel Width="Auto" Height="Auto" Margin="0,8,0,0">
                                        <TextBlock Text="{Binding DisplayName}" FontWeight="Bold" FontFamily="Arial" FontSize="14" Foreground="Black"/>
<twilightBlue:TwilightBlueTheme>
                                            <Controls:DefaultComboBox Background="#CC264984"  ItemsSource="{Binding RefinementValues}" SelectionChanged="ComboBox_SelectionChanged" SelectedItem="All" >
                                                <ComboBox.ItemTemplate>
                                                    <DataTemplate>
                                                         <Border Background="{x:Null}" BorderThickness="0">
                                                            <TextBlock Foreground="#CC264984"  Text="{Binding Path=Value, Converter={StaticResource RefinementFormatter}}" FontSize="10" TextWrapping="Wrap" />
                                                        </Border>
                                                    </DataTemplate>
                                                </ComboBox.ItemTemplate>
                                            </Controls:DefaultComboBox>
</twilightBlue:TwilightBlueTheme>
                                    
                                    </StackPanel>
                                </Border>
                            
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

            </StackPanel>
        </Border>


        <Button x:Name="btnRefinement" Template="{StaticResource refinementButtonTemplate}" Margin="20,16,10,10" Background="{x:Null}" Height="26" BorderThickness="0" Click="btnRefinement_Click"  HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="{Binding IsRefinementDataAvailable}" />

        <View:ImageDetails Grid.Row="0" x:Name="imageDetails" Grid.RowSpan="2"  SubImageMetadata="{Binding CurrentImageContext}" VerticalAlignment="Stretch" Margin="0,0,0,0" d:LayoutOverrides="VerticalAlignment" HorizontalAlignment="Right" Width="250"/>

        <View:MainMenu Margin="45,0,5,0" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" ZoomIn="MainMenu_ZoomIn" ZoomOut="MainMenu_ZoomOut" NavigateHome="MainMenu_NavigateHome" ToggleFullScreen="MainMenu_ToggleFullScreen" ToggleSlideShow="MainMenu_ToggleSlideShow" NextImage="MainMenu_NextImage" PreviousImage="MainMenu_PreviousImage"/>

        <!--<View:FlyThroughInfoPopup Grid.Row="1" Grid.Column="1" x:Name="FlyThroughPopup" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,40" PlayFlyThrough="FlyThroughInfoPopup_PlayFlyThrough" HideFlyThrough="FlyThroughPopup_HideFlyThrough" ShowPopup="{Binding ShowFlyThoughInfoPopup}"/>-->
    </Grid>
</UserControl>
